package com.up360.rapidcalc.aerolite.model
{
    import flash.display.MovieClip;
    import flash.display.DisplayObject;

    /**
     * @author Tunie
     * @date   May 2, 2013
     * 炮座
     */
    public class GunPlatform extends GameElement
    {
        private var _state:int=0;
        public function GunPlatform()
        {
            super();
        }
        
        override public function set ui(value:DisplayObject):void
        {
            checkUI();
            _ui = value;
            state=1;
        }
        
        /**
         *炮台状态，有三种状态
         * 1－正常状态
         * 2－禁发状态
         * 3－毁灭状态 
         */
        public function set state(value:int):void
        {
            if(value<1||value>3) return;
            if(_state==value) return;
            _state = value;
            updateState();
        }
        
        private function updateState():void
        {
            if(_ui)
            {
                if(_ui is MovieClip)
                {
                    var b_ui:MovieClip=_ui as MovieClip;
                    b_ui.gotoAndStop(_state);
                }
                else
                {
                    trace("炮台UI设置出错！");
                }
                    
            }
            else
            {
                trace("炮台UI为空！");
            }
        }
        
    }
}